Fix logic error with checkboxes