I think we should use the full encoder of the resource here, rather than trying to mimic it.
(I thought this bit of code has already been done)