Added comments and fixed query