refactor the writing of the disparity in to a generic function.
cleaned up the main loop.