Added checking for empty strings