Fixing decoding method. Tested on OSX