Solved bug in navigation system and improved the readability of code