refactored _With API and added foreachPartition