Fixed a bug where it would crash because the 'lang' was nil

Forgot to add this in the last changes.

This would crash if the variable "lang" was nil. For example if I wrote "x + x + x" it would not recognise any language and return nil into "lang" and crash when trying to change the input language.