refactor enum code