updated solution 3