Refactored some more code