better handling of layers