Refactor work modal code