refactor getFriends logic