Cleanup
Sql query tidied up