Fleshed out algorithim, added IndexOutOfBounds exception