reorder helper definitions to precede their usage