some refactoring: putting all the boundary logic into a (new) boundary class