Fix a bug in navigation logic.