code factorization in the find method