add error handling to decode data