After you've been able to
MakeItWork, when you need to,
MakeItWorkBetter.
You and your customer/user/client will define "Better" in the context of the problem. Sometimes "Better" means faster, sometimes it means "So that another routine can use this", sometimes it means "so that this can solve a similar problem".
Your
UnitTest will help you
MakeItWorkBetter without breaking it.