improved empty string handling