Fixed bug with layering