added toggle logic