Refactored code and added setSize methods