fix errors in previous code, solved problem 50 and 49