move functions into a separate .py file
move functions from main script to here