Replace find by a loop