adding solution for secon problem