some MC simulation code