Altered csim to construct its own sim function.