fixed array out of bounds bug in context