added if statment to prevent DOM not found error when no agents
might be working
jquerry not working still
reinstated headless