Restructuring  Frontend code