extracted function to find adjacent squares