Fixed simulate function