Added missing null-check to fix NPE