Refactor empty() check within single if statement