Final version with 3 levels and a random switching between them.