Square class created and refactor and bugfix