Refactor almost complete