Moved utility functions to utils.py