fix bug with NULL values