Refactored code. Now with Objects