solving problem 24
solving problem 28
solving problem 30