added getNextTarget procedure