added error probability function