problem3 (too slow)