fixed loop problem