Fixed a minor bug in the control flow.