Refactored more code