Added a helper function to check if a square reverses detector readings