Further improved db search function