Removes duplicate code from navigation toggle