fix cache of rdd, refactor