Fix bug in simulator