changed i and j to x and y for convention