fix recursive query issue