moved setting of key