Refactor index table writer