Refactored JS method searchDB.