added error handling to init/login