updated checkKey function