Correct logic, but not finished.