Removing redundant code in search modes