moved serialize() out of class