updated last_two function