Fixed bug in "find guards" algorithm