encoding/decoding optimization utils