Refactor square as class