Restructure to separate util methods in utils.py