Remove two-iteration loop from check_keyword_id