Changed login to allow error handling