You've got a duplicate and expansive if() check, why not handle the qdel(O) and user message print at once somehow?