Corrected the check whether a target is reached.