Changed global variables to local in navigation