added logging of err