move layers to functions