Created method for determining if a key is valid