ho risolto in modo più semplice...

considerando che totPage non può essere < 1 ho impostato page a 1...