added most of the login/register functionality