improved createTable method