one day i went to a place which was more than 40 km far away from my house. I recited the namaz qasar as per the rule.. Now while returning home I reached under the radius of 40km from my home, while the namaz time was left( meaning it had not become qaza yet). So, do i need to pray namaz again because I reached under 40km before that namaz has become qaza? Thanks

If the distance you traveled from the boundary of your city one way 22 km
Or more than22 km
Then namaz is Qasr. Remember journey will not start from home it will start from boundary of the city or town.
In above masala you don't need to repeat your Namaz is valid and in order