refactoring for check if two squares have wall between