restructuring code hierarchy