added serialize object function