Maybe this function should be in a separate functions.py file?