fix kardex queries