added support for multiple layers