fixed inf loop