refactor using sample