solved using C