added all these things to stop crahses