initial decode function