Use common query / api methods and clean up logic