Refactored more code, not 100%