Refactor JS and checkbox default check