Added a check to see if string is empty
Codingbat format