fixed database lock bug