very rough draft of decoder