Added comments and adjusted a query