flatten layers