changed decode function