fix variable scope in table