added the test data and input enhancement to algorithm