Solve enum cast error