handle margin when layered = true