(2)Where immediate action is necessary, the Secretary shall, before giving such notice or before the period of such notice expires, cause to fence off, take down, secure, demolish or repair such structures, or fence off a part of any street or take such temporary measures as he deems fit to prevent danger, and the cost thereof shall be recoverable from the owner or occupier in the manner provided in section 538.