fixing the nullpointer on type which is null