changed int to size_t to avoid comparing signed and unsigned ints