fixed some bugs: in sim3 and sim2, the scalar can be negative.