fixing some errors and making the distributed code runnable