refactor renderHomePage function