re-organized  sql command