refactored code;