refactored main method of square detector into own class