Refactured code