Layer not defined bug fixed