correctly check if lastFiltered is undefined