I think your mistake is in calculating totalseconds . I can see that totalminutes is cumulative, but totalseconds is not. It just equals whatever timeseconds is.
And you should also include an if-statement or something to check for the condition when totalseconds goes up to 60 or more.