protected function _loop($action, $model, $operations = [], $options = []) {
		if (!in_array($action, ['generate', 'remove', 'regenerate'])) {
			$this->_stop();
		}

		$totalImageCount = $this->_getCount($model);

		if ($totalImageCount === 0) {
			$this->out(__d('file_storage', 'No Images for model {0} found', $model));
			$this->_stop();
		}

		$this->out(__d('file_storage', '{0} image file(s) will be processed' . "\n", $totalImageCount));

		$offset = 0;
		$limit = $this->limit;

		do {
			$images = $this->_getRecords($model, $limit, $offset);
			if (!empty($images)) {
				foreach ($images as $image) {
					$Storage = StorageManager::get($image->adapter);
					if ($Storage === false) {
						$this->err(__d('file_storage', 'Cant load adapter config {0} for record {1}', $image->adapter, $image->id));
					} else {
						$payload = [
							'entity' => $image,
							'storage' => $Storage,
							'operations' => $operations,
							'versions' => array_keys($operations),
							'table' => $this->Table,
							'options' => $options
						];

						if ($action == 'generate' || $action == 'regenerate') {
							$Event = new Event('ImageVersion.createVersion', $this->Table, $payload);
							EventManager::instance()->dispatch($Event);
						}

						if ($action == 'remove') {
							$Event = new Event('ImageVersion.removeVersion', $this->Table, $payload);
							EventManager::instance()->dispatch($Event);
						}

						$this->out(__('{0} processed', $image->id));
					}
				}
			}
			$offset += $limit;
		} while ($images->count() > 0);
	}