Amost working having trouble with array out of bounds exception