added logging for errors