the first commit i did was all wrong .This is the correct code