fixed array out of bounds errors