Refactored, moved empty string check
Refactored, renamed variable for consistency