First attempt, has arrayindexoutofbounds exception somewhere