rewrite using functions -source it in bash_profile