More than 500 inmates are being evacuated from a prison in western Germany after experts said parts of the building were so dilapidated they could collapse any time.

The prison in Muenster is one of the oldest in Germany — parts of it are more than 160 years old. The first inmates were taken to prisons in nearby towns by bus on Thursday and the evacuation was to be completed by mid-Friday, news agency dpa reported.

Prison warden Carsten Heim said the move was unavoidable.

Authorities have planned since 2012 to build a new prison in Muenster but haven't yet found a site for it.