added browser action and improved code