Fix the onhand query issue