refactor working