some more work, fixed infinite loop in a bad way