This query is duplicated here and above, could put everything before the result in a well named method.