Moved code from simulate() to tick()