If, after such notice and hearing, the magistrate court determines that the dwelling, building, or structure in question is unfit for human habitation or for commercial, industrial or business use and not in compliance with applicable codes; or is vacant and being used in connection with the commission of a drug crime; or which constitutes an endangerment to the public health or safety as a result of unsanitary or unsafe conditions; or has defects increasing the hazards of fire, accidents or other calamities; or which lacks adequate ventilation, light or sanitary facilities; or other conditions exist rendering such dwellings, buildings or structures unsafe or unsanitary or dangerous or detrimental to the health, safety or general welfare of the people; or which renders adjacent real estate unsafe or inimical to safe human habitation, the court shall state in writing findings of fact in support of such determination and shall issue and cause to be served upon the owner and any parties in interest that have answered the complaint or appeared at the hearing an order: (a) If the repair, alteration or improvement of said dwelling, building, or structure can be made at a reasonable cost in relation to the present value of the dwelling, building or structure, requiring the owner during the time specified in the order to repair, alter or improve such dwelling, building or structure so as to bring it into full compliance with the applicable codes relevant to the cited violation and, if applicable, to secure the structure so that it cannot be used in connection with the commission of drug crimes; or (b) Tf the repair, alteration or improvement of said dwelling, building or structure in order to bring it into full compliance with the applicable codes relevant to the cited violations cannot be made at a reasonable cost in relation to the present value of the dwelling, building or structure, requiring the owner, within the time specified in the order, to demolish and remove such dwelling, building or structure and all debris from the property.