Added error catching to decoding method; still troubleshooting encoding