The script crashes of course when T is 0. You must always check that.