Refactoring to do, but working