Fixed counting errors and loop mistake