added shallow to flatten