printing table as required. needs testing.