check if key is valid