use enum to refactor the code