move function from core.py to utils.py.