added serialize function