add basic authentification. Code refactoring.