reduce until the end