refactored friendship functionality