That looks better, but still a bit misplaced. Normally you place the optimize call just where you use that parameter. But of course before any return statements, whichever comes first.