refactor. this method is now used in 2 places. see below.