fixed a bug and sql scrubbing