Removing redundant code in search modes 2