refactor: split subqueries and better names