Move utility functions into separate module