improvements to render function where by it makes use of the module pattern to seperate logic from api usage