private static void draw(int prevX, int prevY, int x, int y, char[][] map){
        if (onMap(x, y, map) && map[x][y] == 'X'){
            int dx = x-prevX;
            int dy = y-prevY;
            //make sure the next tile is on the map and hasn't been drawn to yet
            if (onMap(x+dx, y+dy, map) && map[x+dx][y+dy] == 'X'
                    && onMap(x+dy, y+dx, map) && map[x+dy][y+dx] == 'X'
                    && onMap(x-dy, y-dx, map) && map[x-dy][y-dx] == 'X'){
                map[x][y] = ' ';
                
                int[][] deltas = {{1,0},{-1,0},{0,1},{0,-1}};
                Random rand = new Random();
                int start = rand.nextInt(4);
                
                for(int i=0; i<4; i++){
                    int di = (start+i)%4;
                    draw(x,y,x+deltas[di][0],y+deltas[di][1],map);
                }
            }
        }
    }