factored out common functions