Fixed array out of bounds issue in polarbear