Corrected the writing condition for layer and surface. Used to require approach or representing surface to be empty instead of not being empty.