Thanks for replying!
I've tried to change the 3 lines and re-compiled the extension. The codes are slightly different but yes the problem is solved :) Thanks again!
(Here are the codes that I changed)