Added checkboxes and refactored some code