code restuctured