Added changes in input string interpretation, changed to handle any number of inputs