Rewrite the code using handlers.