Corrected filtering so it functions with null data.