I'm ok with not supporting providers for now. But the code would be easier to follow if the handling of each type was moved to separate functions.