If your family is anything like mine, bedtime can be a nightmare. Something that was supposed to be a calm and relaxing ritual turned into World War III every night between my five-year-old daughter and me. Some nights it was so bad I’d give in and let her stay up until she passed out doing whatever activity caught her attention that night—even if that meant she was going to bed at midnight and had to be back up at 7 a.m. for pre-K the next morning.

Something had to give, which is what sent me searching for new bedtime strategies. Here are some tips and tricks I picked up along the way. Hopefully, they’ll help preserve your sanity as well.

I Had Tried Everything

I’m not exaggerating when I say I tried pretty much every strategy in the book to get my older daughter to go to bed at the same time every night.

  • Warm baths
  • Cool baths
  • Lavender essential oils
  • Screen time
  • No screen time
  • Lullabies
  • Bedtime stories
  • Quiet rooms
  • White noise
  • Blackout curtains
  • Nightlights

And that’s just part of the list. I don’t expect too much from my younger daughter—she’s five months old and sleeps most of the day anyway, but my older, a five years, should be getting between 10 and 13 hours of sleep every night. At most, she was getting six to seven hours, which led to epic tantrums during the following days.

Here’s what I came up with, after many sleepless months of trial and error.

1. Stay Active During the Day

Even on school days when she’s active all day long, bedtime was a nightmare. That was in large part because we’d come home, do homework and plop down in front of a screen for the rest of the day while I finished my writing work.

Don’t do this. Learn from my pain and the bags under my eyes so big that I’m thinking of starting a designer luggage line.

Stay active as much as possible during the day. One of the most natural changes we made was getting outside in the afternoons. I’d throw my laptop in my bag, put the baby in her stroller and walk to the local playground to let my little monster burn through some of that energy. While it isn’t the most efficient way for me to work, it helped her get rid of some of that energy she’d built up throughout the day and made bedtime a little bit easier.

2. Set a Routine—and Stick to It

Experts have been telling us for years that our little ones benefit from a sold structure in their lives, but most of us still try to fly by the seat of our pants and that goes double for bedtime. We’d get wrapped up in our little worlds and by the time we realized it was time for bed, we were all too busy to keep up with a routine. That led to a lot of fights and something had to give.

The second change I made was to set up a semi-strict bedtime routine. I even set alerts on my phone to remind me when it was time to shut off the screens, take a bath and wind down for bed.

This strategy won’t work for everyone—parents of children with special needs may need a more flexible routine to accommodate their child’s tastes—but a comprehensive method can help get your little ones into the habit of going to bed at the same time every day without a fight.

3. Ditch the Screens Before Bed

This rule shouldn’t apply only to your children—it should be a household guideline. We’re all attached to our mobile devices and our screens, but the blue light they generate can disrupt your circadian rhythms and make it harder for you to fall asleep. Studies have shown LEDs suppress delta waves, the brainwaves that induce sleep.

Set a timer and shut off all screens—phones, tablets, computers and televisions—one to two hours before bedtime. As part of your consistent routine, this step can help reduce those bedtime battles. It might lead to some other squabbles—especially if your little ones are enthralled with what they’re doing at the moment—but in general, it will help make sleep come easier.

4. Customize Bedtime for Your Child

I had to learn this lesson the hard way. Hundreds of websites offer routine templates and step-by-step help to you put your little ones to bed—but there’s no guarantee the solution that works like a charm for one family will work in your household. Take the time to build your routine and customize it for each child.

Remember that massive list of things I tried? I ended up having to choose a small handful of things that worked best for my older daughter. In her case, it was limiting screen time, coupled with a warm bath and a bedtime story to help her slow down at the end of the night. When my younger daughter gets a little older, I will have to create a custom bedtime routine for her as well.

5. Success Requires Patience

It takes weeks to form a new habit, but constant repetition helps rewrite the pathways in your brain until an activity becomes second nature. Be patient with your children and with yourself. Sleep deprivation is a hell of a drug, but if you can be patient for a few weeks, you may not have to worry about bedtime battles ever again.