added sample & flatten, and object filtering