Making a last pair function