refactored some more code