Fix square method and modify for-loop in main