Have you replaced the original code so there are no conflicts? It works fine here based on what you have said.
Which line causes the error?
I don't think we can take this any further without access to one or two original messages.