Bug fix: preventing NPE