how to calculate depreciation of the commercial rental property for the year it is sold

I purchase the commercial property ( one store and two apartments) in March 2018. The total purchase cost was

$172,157.00 . I sold it on Sept 9 , 2021. In 2021 I did some improvement which cost about $50,000.

Question 1.

Do I put the improvement cost $50,000 as expense in 2021 or I can add $50,000 as basis cost ?

Question 2,

The first year depreciation with 39 years straight line is 158,657( exclude land cost) * 2.033%=3221

The second year and 3rd year's depreciation is 158,657*2.564%=4068

I don't how I can calculate the depreciation of 2021.

1.which month and which percentage do I use?

2. Can I add $50,000 to $158,657 as the basis cost to calculate 2021 depreciation?

Thanks,