The Next Palindrome Wrong Answer

I am submitting this code after thinking about all possible test cases but it is giving me wa.
Any suggestions would be of great help.
The link is
link text

Check for this case 12199121. Your code gives 12111121 which is less than input.