cleanup sql a bit