minor re-org of code