Changed counter from size_t to int to avoid warning.