first version of Spark code