slight refactor of select_friend() and fix mistake