Fixed checkbutton function