optimized the implementation of keys.