refactored code to include render function