refactor render method