First version of login and added error returning function.