minor code restructuring