Code re-structure