updated query writers function