fixed if clause for detect