Refactoring code for creating SVG file.