changed sql query
Fixed sql queries
cleaned up comments