updated docs
factored out duplicated code