refactured simulator