adding changes to try and catch negative array exception