refactored object and organized code