Added some null checks before converting to lowercase