proper function to compute probability