Would you mind moving this function to its own library file?