refactored some code parts