added flag to prevent multiple openings of browser