Added an optimized probability calculator