working out refactor