null handling added