Refactored my code