updated solution #3