implemented class shape and lots of refactoring