bug corrected, 'small' changes in way it read the input