Refactor code to use enum instead of weird traiting