Added logging of errors