Move utility functions to utils