overtaking algorithm