corrected script for extracting depenedents