added checks for empty tables, comments