Code re-structured