altered inventory page to use optimized queries