MOve helper functions to anonymous namespace