Finish the function first, then optimise.