Refactor Spark Module