I think that output is ok, and the logic is ok.