refactor, fixed bug with auth