minimized the sql