I got it to work...initially i though that the 1ms pause and i am doing a 10000 loop i would get about 10 seconds delay...but it turned out that this is not correct i would get about 56 seconds delay for 2700 loop not sure why it took so long to execute all these functions