Refactoring the solution applying the 'replace with query' technique