handles multiple cases problem 4