Added Guard in HEADLESS mode