seems to be working, though sum is confusing to use