Check all checkbox now functional, refactored some code