Code re-arranged