added a function to choose something based on probability