Improving code of quick find algorithm

Making this code smaller and easier to read