You’re in the shower, mindlessly scrubbing your toes when—bam!—a prophetic thought pops into your head. Maybe you finally solve that glitch bugging you at work. Or maybe you learn something terribly more important. The meaning of life, perhaps. Or what the 23 flavors in Dr. Pepper are.

Those aha! moments aren’t locked inside a bottle of Irish-scented shampoo. Soaking yourself in suds, though, does have a lot to do with it. The shower creates the perfect conditions for a creative flash, coaxing out your inner genius. Oh, and it makes you clean, too.

Mind Your Mindless Tasks

Research shows you’re more likely to have a creative epiphany when you’re doing something monotonous, like fishing, exercising, or showering. Since these routines don’t require much thought, you flip to autopilot. This frees up your unconscious to work on something else. Your mind goes wandering, leaving your brain to quietly play a no-holds-barred game of free association.

This kind of daydreaming relaxes the prefrontal cortex—the brain’s command center for decisions, goals, and behavior. It also switches on the rest of your brain’s “default mode network” (DMN) clearing the pathways that connect different regions of your noggin. With your cortex loosened up and your DMN switched on, you can make new, creative connections that your conscious mind would have dismissed.

That’s why the ideas you have in the shower are so different from the ideas you have at work—you’re a pinch more close-minded at the office. Thinking hard about a problem deactivates your default network. It boosts your prefrontal cortex’s control. This isn’t a bad thing—it tightens your focus and gives you the power to stop gawking at cat pictures and hit that deadline. But it can also dig you into a creative rut. Because when you’re deeply focused on a task, your brain is more likely to censor unconventional—and creative—solutions.

Strange as it sounds, your brain is not most active when you’re focused on a task. Rather, research shows it’s more active when you let go of the leash and allow it to wander. Shelley Carson at Harvard found that highly creative people share one amazing trait—they’re easily distracted. And that’s the beauty of a warm shower. It distracts you. It makes you defocus. It lets your brain roam. It activates your DMN and encourages wacky ideas to bounce around. So when the lather rinses off, your light bulb switches on.

And Relax!

But what makes the shower different from a boring board meeting? Doesn’t your mind wander there, too?

Well, yeah. You probably have the doodles to prove it. But a shower is relaxing. It’s a small, safe, enclosed space. You feel comfortable there. (Comfortable enough to be in the buff!) On top of that, you’re probably alone. It may be the only alone time you get all day. It’s your chance to get away from any stresses outside.

When you’re that relaxed, your brain may release everyone’s favorite happy-go-lucky neurotransmitter, dopamine. A flush of dopamine can boost your creative juices. More alpha waves will also ripple through your brain—the same waves that appear when you’re meditating or happily spacing out. Alphas accompany your brain’s daydreamy default setting and may encourage the creative fireworks.

Wait! There’s more! The time you shower also plays into the equation. Most of us wash up either in the morning or at night—when we’re most tired. According to the journal Thinking and Reasoning, that’s our creative peak. The groggy morning fog weakens your brain’s censors, keeping you from blocking the irrelevant, distracting thoughts that make great ideas possible. It’s likely that your shower gushes during your creative sweet spot.

There you have it. You’re distracted, relaxed, and tired. Your prefrontal cortex slackens its power as your default network switches on, your dopamine supplies surge, and your alpha waves roll. The shower creates the perfect storm for the perfect idea.