working on critical section... code generates  but output is wrong