Fixed array index bug and also single boundary point bug