generic helper functions moved to helpers.py