trying to make multilayer function