Make the method for serialization a function.