Beamforming based algorithm for 5G applications