refactor createtables.py