completely changed choosing algorithm