Got the decode function working