starting decode function