refactor work code