fixing search logic once again for bugs, DRYd up code for main getDoctors function