Added missing if clause. Added missing cache reset call.