refactored code into helpers.py