minor code reordering