updated code with apis integrated.