Refactored code and updated rendering