fixed the sql