Optimized code for Key