Improve rendering code