add method to flatten blocks