refactored out helper functions

moved helper functions to separate file to help clean up web.py