add comments. refactor out methods.
add comments. refactor out methods.