changed validate function, now it can take all the values from checkboxes too