refactor "same" routine