move cloneLayer to func in closure and implement for more layer types