added sampling chaos code