Moved helper function to helpers.py