added code

added from prac 4 code