added tableExists(), changed formatting