changed method name to 'authenticate' and refactored throughout