Fixed the None value in the distances array bug