Small code re-structure