add exception handling for decode