refactored/repackaged to reflect auth change etc