reorganized layer code