refactor the type discovery API