#1: refactor query