Fixing an issue in sum