Fixed a bug in the navigation function.