Add sinkmode and change output query to a function