Code refactored;