small refactoring around wrapInSAM()