added eror logging