added logic to select numbers