safeguards to prevent potential crashing