The problem is actually a lack of curly bracers, to wrap the check into the while loop. If you don't follow a while or if statement with curly bracers it will only cover the first command right after, so right now, it's trying to visit the location repeatedly, and only after that while loop...