refactoring: fix potential null pointer