Added decode function