Write errors on stderr
Wrap bd into a function