refactoring orders query and table display