Use size_t for capacity instead of int