Problem7 solved. Fixed wrong function in problem3