He calls us Friend

It was said that Lazarus was someone that Jesus loved. But how could Jesus treat a friend like He did? Why would He callously stay away while this close friend died… and He could have prevented it?