Addition if block to avoid NPE