autolayer function

Autolayer generic function