refactored, commented, cleaner rendering method