problem 7 solved but a bit slow