fix a bug when building more that one layer