refactored sample manager