refactor 95% done