refactor and move stuff around