added function to serialize