updated to allow username and token file to be specified