fixed bug in bilayer