bug fixes. array out of bounds