Fixed bug in simulator