fixed a bug in navigation function