Move utility functions at the top of the file