fixed bug because of ambiguous sql