Refactor sim funk