Probably solved array access issues

Still have to add the boundary checking