refactored render function for comparable call overhead