working soln for test data; fails for all inputs