error rendering refactored