Code re-write