refactored some lines