Update and improve docs
Refactor and simplify the toggle function