Fixing bug with filtering