Made the following changes
1. Wrapped integrate with NotImplementedError
2. Used islice
3. Replaced nested if
4. Used continue