converted to google apps script