Adding a mode generation function, so that people can be somewhat more happy.