Checking the solution and reorganized a little