refactor friendship logic