move utility functions to util.py