reorganized the code such that most of the processing is able to be separate from the interface parts