minor code reshuffling