Fixed bug with layers