refactored to use scala-pickling