refactoring + fix checkbox bug