Add method checking for valid credentials
Refactor