added modularity by introducing the getdatafunction