implement window to find the corresponding next peak flow