cleaned up sql