Move utility functions into a separate file