refactor and clean up.
clean up and refactor