this code is a little hard to understand...
if ($page > 1) ... are you using negative values? When is '$page' ever less than 1? Could you post more of the code? As it is, I can't understand the logic... and, on another note & just out of curiosity, why are you placing your comments after the code for which they are meant?