Converted script to functions for sourcing in .bash_profile