Written code for dependency construction; still needs debugging