Fix return value of toggle function