Added safety measure that prevents the algorithm from detecting burrows
outside of the cage frame