cleaned up toggle code