refactored render method