cleaned up authentication js
another small refactoring