fixing loop