handle empty strings correctly