Modified decode function

The decode function was modified to return the first value of the resulting array with a second parameter to specify if an array should be returned instead.