simplified code, let jQuery handle the loop