serialize refactoring
alternative implementation for variant