Bugfix: fixed query for maximum points