guard against text being None which makes indexing fail