make search for a random free field more fail safe on the edge of the map

also get rid of a while true loop