public void run()
    {
        edge.addElement(GridCell.getStartCell());
        int attempts =0;// variable to count how many attempts
        int state=NOT_FOUND;
        while(state==NOT_FOUND && attempts<maxSteps)//while a path hasnt been found and the whole grid hasnt been checked
        {
        	attempts++;
            state = step();//sets state to output of step

            try
            {
                Thread.sleep(speed*10);//sleep 
            }
            catch(InterruptedException e){}
            
        }
        
        if(state==FOUND)//if a path has been found
        {
            try 
            {
				Path.setPath(map);//runs the find path method in the path class
			} 
            catch (Exception e) 
            {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        }
        else
        {
        	System.out.println("No Path Found");
        	JOptionPane.showMessageDialog(null,"No Path Can Be Found");
        	AStar.running=false;// sets the booleans to false to let the searches run again
        	Dijkstra.running=false;
        	GridCell.startmove=false;
        }
    }