rewrite for Spark 2.0.0