refactor nLayers and init layers