rewrote though I'm having trouble with the array
finally working