restructered the solution