working solution to #2