refactored auth