better error handling for empty tables implemented