fix faulty mysql querys