I cleaned up the code and improved the checkbox functionality