fix settlement logic