Inside |json| we use |var limit = Math.min(count || keywords.length);|. I don't mind which solution you pick but let's try to keep similar logic.