correctly check if lastFilter is undefined