restructure the exec sql