fixed serialize to handle mixed types