improved read and decode usage and correctness