Performance improvement by implementing doCalculateKey
use calculateKey instead of doCalculateKey