Added most of the authentication