Factor out create tables method