added mode to argument of iterate