use the same logic to solve similar problems, fix a reduce