simplify function detect