Fix detection of the final position