Improve the code

Improve the code to slove "Crash when adding new building".