Updated prog_sum with cleaner code