ALM-237 added better data handling logic