fix crashing problems