Refactor: moved the empty string case to a guard clause