first draft of decoder