added dynamic slicing method 1