refactored authetication, delete key added and code indention