refactor recommend function