diff --git a/stack.c b/stack.c
index 880491a63806064ccce414593ad895d3a3cb9708..d538b8462e116136bed1d5ac8c5a1b1cfd79efbf 100644
--- a/stack.c
+++ b/stack.c
@@ -17,9 +17,10 @@ void stack_destroy(stack *s) {
 
 void stack_push(stack *s, int value)
 {
-    if (s->top == DEFAULT_CAPACITY-1)
+    if (s->top == s->capacity-1)
     {
-        assert(s->data = realloc(DEFAULT_CAPACITY * 2 * sizeof(int)));
+        assert(s->data = realloc(s->capacity * 2 * sizeof(int)));
+        s->capacity=s->capacity * 2;
     }
 
     s->top++;