fixed error logic.