add multi stage function