find algorithm