Could you make a function that can do that same conversion, but without using a library? Just one condition and no joins is fine.