all done, some ugly things to refactor