got first stage refactor working