refactored utilities.py