move utility functions into utils.py