RDD transformation was in wrong order