fixed infinite loop, test cases next