fixed new detection to be not undefined and not null