Sometimes writing down helps you find the defect - and I often start any relatively complex automation by writing it all out anyway. Gives me some perspective, and I usually find ways to either speed it up or make it less complex as I go. I'm motivated to do so, as writing it out isn't all that fun.