Corrected so whether or not type key exists becomes the deciding logic