allow spaces in usernames
Move learn api code into own function and wrap with a try block