checkboxes functionality. Re-factoring