improving the solution 2