Refactored, function hoisting