little bit refactored code