Adapted solution to 76