modified the code base on comment in https://github.com/tdas/spark/pull/10