Simulator working and refactored