added better data handling