fixed last target logic