Looking into the code it seems like the check for tok!=null is unnecessary.