use bash not sh
added logging