Less supergeneral but working solution