Was incrementing wrong variable