modification of an algorithm for checkboxes with respectively selected values