more sql fixing