Converted some scripts to bash functions