nil pointer execption

fix acessing invalid qid