move function closer to its call site