added toggle feature
pulled from upstream