Changed to better handling of input data