Corrected wrong check for key