moving some code around so that each class has better responsibility for
itself