Refactor Dana's code