Refactored for leaner code.