spark implementation