factored common initialization code out