refactored primitive rendering