updated toggle funtion