make Key function more flexible