fix potential null pointer exception