refactoring orders index function