Refactor search function to filter record also with data range.