compacted the logic to check boxes