updated version with support for groups of friends and n_hops