refactor codes/table