While forwarding the second call when one call is running

hi,
I made one script such that it calculates the time according to the balance and call cost and limit the call for that time and after the call get over according to the answered time i’m calculating the call cost and reducing it from the balance.

But the problem is while one call is being answered,if second call arrives and person lifts the second call and the first call is on hold…the second call is also having the same time and balance as the previous one because i’m altering the balance after the call got over…but here the first call is still on hold.

Any solution for this problem??? please help me… :confused: