Added small bits of code to organize the data communication