Where you have "A/B" change to "if (B=0,0,A/B)"