small code re-structure