hacked together first version of type conversion