refactored code!