fix crash on element encoding