moved data processing and labeling to functions