Refactored behaviors to separate functions.