refactored js_valid_decode to use reader_or