Working with given test case so far. May not have handled all corner
cases.