updated solution to #1