fix a bug in duplicate layer