Fixing bug with length filtering