updated solution #6