added decode function for collectN