factored out survey code