Rewrite key matching