updated simulator and merged with wangda's code