Moved functions to bin scripts to allow for easier execution from cron job