an modified version for mysql