consolidation and cleaning up some code