Refactor render process