Improved the SQL