Refactored codes for homepage and profile's page.