modifying building selection algorithm