added logic to check boxes