Refactor rendering