Fixing NPE vulnerability caused by last commit