Extract utility function to util module