fixed loop number error