Added checkKeys function