Added code for automatic navigation.