fixing a NPE when null in a column + small optimization