Delete function corrected

No more index out of range exception