Refactor moving code