Fixed Array Index Out of Bounds Issue