Added check to avoid NPE.