authentication fixed, refactoring