partially restructured code