optimize code by using already assigned variable, directly using the friends array.