fixing sql