updated cosim code