Write control component, refactor code using new api