fix backwards logic in detect