Made the following changes
1] Raising error
2] Replaced .sum with enumerate