array out of bounds issue fixed