refactored template to support improved user auth