implement function for converting key to corresponding type