fix potential NPE, throw failure only if exists