using a similar technique for checkboxes and radio buttons