updated code so that it works with webauth and totoro