some code re-org