refactoring for easier reuse and recombination of layer types