Refactor conversion and template