added login and improved register functionality