fixed error logging bug