refactoring on empty string check