clean up and refactor.