Modified pipeline code to not have index errors.