debugged probability function