Clean up into bash functions