fixing check for non-existant tables