Refactors check for empty