custom sql fixed