Code refactored