Modified solution's structure and fixed the existing errors