generate all keys with loops