Refactor Spark js framework