minor code alterations - still untested