Updated sql queries