Added extra check for empty strings (consisting of spaces)