added ent decoding and sorting