Checks valid squares but needs refactoring