Thanks for your inputs Gerrit. Much appreciated.
I have moved the data declarations to the top and still getting the same results. And yes mod 2 should be mod t.
And also thanks for letting me know regarding the constants , would be really helpful.