in reply to Improving the efficiency of this piece of code
Secondly rather than calling functions using: &index; it is better to call it with index(); so you don't accidentally pass in the wrong parameters. (The first form reuses your current parameters.)
Third I would suggest that you have a final case that reports what the parameter was and that it was not understood. This will help debugging when (in my experience not if) things go sour.
Fourth in chatter you got the suggestion to call param('page') once and put that in a variable. That idea is a good one.
I could add more, but this is probably more than enough to digest at one go...