add safety checks.