an ok but slow version