put a toggle function in the view and controller