var seconds = total_secs;


No.

You need to set this in a while (without the the var in the while).