have prob489 working for smallest case, but not sure how to generalize
yet