reorder statements in function