added alerts and fixed db error handling