FINISHED and figured out winning code. function must be outside and there was an out of bounds issue.